package com.ruoyi.api.controller;

import com.ruoyi.business.service.IHcxMerchantOrderService;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "支付回调异步接口")
@AllArgsConstructor
@RestController
@RequestMapping("/api/pay")
@Slf4j
public class PayCallbackController extends BaseController {

    private final IHcxMerchantOrderService iHcxMerchantOrderService;



    /**
     * @description: 微信回调
     * @author: kubilewang
     * @date: 2022/9/1 16:24
     * @param:
     * @param: request
     * @param: response
     * @Return: void
     **/
    @ApiOperation("微信回调")
    @PostMapping("/wx/payNotify")
    public void wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception{
        iHcxMerchantOrderService.wxPayNotify(request,response);
    }


    @ApiOperation("支付宝回调")
    @PostMapping("/ali/payNotify")
    @ResponseBody
    public String aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception{
        return  iHcxMerchantOrderService.aliPayNotify(request,response);
    }


    @ApiOperation("银联回调")
    @PostMapping("/union/payNotify")
    public String unionPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception{
        return iHcxMerchantOrderService.unionPayNotify(request,response);
    }
}
